package br.utfpr.edu.dao;

import java.util.List;

import br.utfpr.edu.bean.Gene;
import br.utfpr.edu.business.Negocio;
import br.utfpr.edu.business.NegocioException;
import br.utfpr.edu.utility.Bean;

public class GeneDao extends Negocio{

	private static final long serialVersionUID = 1436058347719687082L;
	private Gene fasta;
	
	public GeneDao(){
		fasta = new Gene();
		limpar();
	}
	
	public void inserir()throws NegocioException{
		fasta.getUsuario().setId(Bean.getIdUsuario());
		super.inserir(fasta);
	}
	
	public void deletar()throws NegocioException{
		super.deletar(Gene.class, fasta.getId());
	}
	
	public List<Gene> pesquisar()throws NegocioException{
		List<Gene> colecao = getList(Gene.class,"SELECT g FROM Gene g where g.usuario.id = ?1",Bean.getIdUsuario());
		
		return colecao;
	}
	
	@Override
	public void limpar() {
		fasta.setId(0);
		fasta.setName("");
	}

	public Gene getFasta() {
		return fasta;
	}

	public void setFasta(Gene fasta) {
		this.fasta = fasta;
	}

}
